#include <iostream>
#include "pimpl.hh"
using namespace std;

class Line::LineImpl{
public:
    LineImpl(int x1,int y1,int x2,int y2)
        :_pt1(x1,y1)
        ,_pt2(x2,y2)
    {
         cout<<"LineImpl(int,int,int,int)构造"<<endl;
    }
    void printLine(){
        _pt1.print();
        cout << "----->";
        _pt2.print();
        cout<<endl;
    }

private:
    class Point{
     public:
         Point(int x ,int y)
             :_x(x)
             ,_y(y)
        {
        }
         void print(){
             cout<<"("<<_x<<","<<_y<<")";
         }
    private:
         int _x;
         int _y;
    };
private:
    Point _pt1;
    Point _pt2;
};
Line ::Line(int x1,int y1,int x2,int y2)
    :_impl(new LineImpl (x1,y1,x2,y2))
{}
Line ::~Line(){
    if(_impl){
        delete _impl;
        _impl = nullptr;
    }
}
void Line:: printLine(){
   _impl->printLine();
}

void test(){
Line line(1,2,3,4);
line.printLine();
}
int main()
{
    test();
    return 0;
}

